An irrational decimal fraction is created by concatenating the positive integers:
0.123456789101112131415161718192021...
It can be seen that the 12th digit of the fractional part is 1.
If $d_n$ represents the nth digit of the fractional part, find the value of the following expression.
$$d_1 \times d_{10} \times d_{100} \times d_{1000} \times d_{10000} \times d_{100000} \times d_{1000000}$$
In [1]:
def champernowne_digit(n):
digits = 1
power = 1
while n > 9 * digits * power:
n -= 9 * digits * power
digits += 1
power *= 10
return int(str(power + (n-1) // digits)[(n-1) % digits])
from functools import reduce
print(reduce(lambda x,y: x*y, (champernowne_digit(10**k) for k in range(7))))
In [ ]: